package com.jule.miaozhuapc.service.impl;

import javax.transaction.Transactional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.jule.miaozhuapc.dao.PayDao;
import com.jule.miaozhuapc.dao.UserDao;
import com.jule.miaozhuapc.domain.WawaPay;
import com.jule.miaozhuapc.domain.WawaUser;
import com.jule.miaozhuapc.service.PayService;

@Service
@Transactional
public class PayServiceImpl implements PayService{

	@Autowired
	PayDao wawaPayDao;
	@Autowired
	UserDao userDao;
	
	@Override
	public WawaUser insert(WawaPay WawaPay) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public WawaUser addCoin(WawaPay pay) {		
		// 添加一条 pay记录
		wawaPayDao.insertPay(pay);
		// 修改user 表中的金币数
		WawaUser user = userDao.findByUserId(pay.getUserId());
		user.setCoin(user.getCoin() + pay.getCoin());
		return user;
	}
}
